package com.tianyuan.dplrf.ui.adapter;


import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatButton;

import com.hjq.base.BaseAdapter;
import com.tianyuan.dplrf.R;
import com.tianyuan.dplrf.app.AppAdapter;


public class Ncjt_f4_tabs_adapter extends AppAdapter<String > {

    int currentSelect = 0;
    public Ncjt_f4_tabs_adapter(@NonNull Context context) {
        super(context);
    }

    @NonNull
    @Override
    public BaseAdapter<?>.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolde();
    }

    public void setCurrentSelect(int position) {
        currentSelect = position;
        notifyDataSetChanged();
    }

    private final class ViewHolde extends ViewHolder{
        private AppCompatButton button;
        public ViewHolde() {
            super(R.layout.item_btn_layout);
            button = getItemView().findViewById(R.id.item_btn);
        }

        @Override
        public void onBindView(int position) {
            button.setText(getItem(position));
            button.setSelected(position == currentSelect);
        }
    }
}